<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta name="keywords" content="天地图"/>
    <title>天地图－地图API－范例－地图放大和缩小</title>
    <script src="http://api.tianditu.gov.cn/api?v=4.0&tk=95f0a5688ec713adb3dd1735533f6fcb"></script>
    <style type="text/css">body,html{width:100%;height:100%;margin:0;font-family:"Microsoft YaHei"}#mapDiv{width:100%;height:800px}input,b,p{margin-left:5px;font-size:12px}</style>
    <script>
        var map;
        var zoom = 10;
        function onLoad() {
            //初始化地图对象
            map = new T.Map("mapDiv", {
                center: new T.LngLat(106.66006,26.13785),
                zoom,
                minZoom: 10,
                maxZoom: 18,
                maxBounds: new T.LngLatBounds(new T.LngLat(107.13455, 26.33773), new T.LngLat(106.3559, 25.64772))
            });

            // var satelliteImageURL = 'http://t0.tianditu.gov.cn/img_w/wmts?' +
            //     'SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default' +
            //     '&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}' +
            //     '&tk=95f0a5688ec713adb3dd1735533f6fcb';
            // var lay = new T.TileLayer(satelliteImageURL, { minZoom: 5, maxZoom: 18 });
            // map.addOverLay(lay);
            // var satelliteImageURL = 'http://t1.tianditu.gov.cn/cia_w/wmts?' +
            //     'SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&STYLE=default' +
            //     '&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}' +
            //     '&tk=95f0a5688ec713adb3dd1735533f6fcb';
            // var lay = new T.TileLayer(satelliteImageURL, { minZoom: 5, maxZoom: 18 });
            // map.addOverLay(lay);

            var satelliteImageURL = 'http://t0.tianditu.gov.cn/ter_w/wmts?' +
                'SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ter&STYLE=default' +
                '&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}' +
                '&tk=95f0a5688ec713adb3dd1735533f6fcb';
            var lay = new T.TileLayer(satelliteImageURL, { minZoom: 5, maxZoom: 18 });
            map.addOverLay(lay);
            // var satelliteImageURL = 'http://t1.tianditu.gov.cn/cta_w/wmts?' +
            //     'SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cta&STYLE=default' +
            //     '&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}' +
            //     '&tk=95f0a5688ec713adb3dd1735533f6fcb';
            // var lay = new T.TileLayer(satelliteImageURL, { minZoom: 5, maxZoom: 18 });
            // map.addOverLay(lay);
        }
        function getCenter() {
            console.log("=======", map.getCenter());
        }
    </script>
</head>
<body onLoad="onLoad()">
<div id="mapDiv"></div>
<div>
    <input type="button" id="button1" onClick="map.zoomIn()" value="放大地图"/>
    <input type="button" id="button2" onClick="map.zoomOut()" value="缩小地图"/>
    <input type="button" id="button3" onClick="getCenter()" value="获取中心点"/>
</div>
</body>
</html>
